<!DOCTYPE html>
<html lang=zh>
<head><meta name="generator" content="Hexo 3.8.0">
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="什么是单例 （这个我就感觉是一堆废话）Singleton:在Java中即指单例设计模式,它是软件开发 中最常用的设计模式之一。 单例设计模式,即某个类在整个系统中只能有一个实例对象可被获取和使用的代码模式。 要点（算是概括的蛮好的，也算单例模式的特点） 是某个类只能有一个实例  即构造器私有化 是它必须自行创建这个实例  即含有一个该类的静态变量来保存这个唯一的实例 是它必须自行向整个系统提供这个">
<meta name="keywords" content="java">
<meta property="og:type" content="article">
<meta property="og:title" content="java学习笔记|单例模式">
<meta property="og:url" content="http://0cmm.cn/2020/05/22/java学习笔记-单例模式/index.html">
<meta property="og:site_name" content="0cm">
<meta property="og:description" content="什么是单例 （这个我就感觉是一堆废话）Singleton:在Java中即指单例设计模式,它是软件开发 中最常用的设计模式之一。 单例设计模式,即某个类在整个系统中只能有一个实例对象可被获取和使用的代码模式。 要点（算是概括的蛮好的，也算单例模式的特点） 是某个类只能有一个实例  即构造器私有化 是它必须自行创建这个实例  即含有一个该类的静态变量来保存这个唯一的实例 是它必须自行向整个系统提供这个">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-05-22T07:57:56.399Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="java学习笔记|单例模式">
<meta name="twitter:description" content="什么是单例 （这个我就感觉是一堆废话）Singleton:在Java中即指单例设计模式,它是软件开发 中最常用的设计模式之一。 单例设计模式,即某个类在整个系统中只能有一个实例对象可被获取和使用的代码模式。 要点（算是概括的蛮好的，也算单例模式的特点） 是某个类只能有一个实例  即构造器私有化 是它必须自行创建这个实例  即含有一个该类的静态变量来保存这个唯一的实例 是它必须自行向整个系统提供这个">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>java学习笔记|单例模式</title>
    <!-- styles -->
    <link rel="stylesheet" href="/css/style.css">
    <!-- persian styles -->
    
      <link rel="stylesheet" href="/css/rtl.css">
    
    <!-- rss -->
    
    
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </span>
    <br>
    <span id="actions">
      <ul>
        
        
        <li><a class="icon" href="/2019/11/22/testImg/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&text=java学习笔记|单例模式"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&is_video=false&description=java学习笔记|单例模式"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=java学习笔记|单例模式&body=Check out this article: http://0cmm.cn/2020/05/22/java学习笔记-单例模式/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&name=java学习笔记|单例模式&description="><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#什么是单例-（这个我就感觉是一堆废话）"><span class="toc-number">1.</span> <span class="toc-text">什么是单例 （这个我就感觉是一堆废话）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#要点（算是概括的蛮好的，也算单例模式的特点）"><span class="toc-number">2.</span> <span class="toc-text">要点（算是概括的蛮好的，也算单例模式的特点）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#几种常见模式"><span class="toc-number">3.</span> <span class="toc-text">几种常见模式</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#为什么饿汉式是线程安全的？（算是自己总结的）"><span class="toc-number">3.0.0.1.</span> <span class="toc-text">#为什么饿汉式是线程安全的？（算是自己总结的）</span></a></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope="" itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        java学习笔记|单例模式
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
        <span itemprop="name">0cm</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2020-05-22T05:33:47.000Z" itemprop="datePublished">2020-05-22</time>
        
      
    </div>


      

      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/java/">java</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h2 id="什么是单例-（这个我就感觉是一堆废话）"><a href="#什么是单例-（这个我就感觉是一堆废话）" class="headerlink" title="什么是单例 （这个我就感觉是一堆废话）"></a>什么是单例 （这个我就感觉是一堆废话）</h2><p>Singleton:在Java中即指单例设计模式,它是软件开发 中最常用的设计模式之一。</p>
<p>单例设计模式,即某个类在整个系统中只能有一个实例对象可被获取和使用的代码模式。</p>
<h2 id="要点（算是概括的蛮好的，也算单例模式的特点）"><a href="#要点（算是概括的蛮好的，也算单例模式的特点）" class="headerlink" title="要点（算是概括的蛮好的，也算单例模式的特点）"></a>要点（算是概括的蛮好的，也算单例模式的特点）</h2><ul>
<li>是某个类只能有一个实例<br>  即构造器私有化</li>
<li>是它必须自行创建这个实例<br>  即含有一个该类的静态变量来保存这个唯一的实例</li>
<li>是它必须自行向整个系统提供这个实例<br>  即对外提供获取该实例对象的方法<br>  （1）直接暴露 （2）用静态变量的get方法</li>
</ul>
<h2 id="几种常见模式"><a href="#几种常见模式" class="headerlink" title="几种常见模式"></a>几种常见模式</h2><ul>
<li><p>饿汉式：直接创建对象,不存在线程安全问题<br>直接实例化饿汉式(简洁直观) </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">   <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 饿汉式: 直接创建实例，不管你是否需要这个对象都会创建</span></span><br><span class="line"><span class="comment">     * (1)构造器私有化</span></span><br><span class="line"><span class="comment">     * (2)自行创建,并且用静态变量保存</span></span><br><span class="line"><span class="comment">     * (3)向外提供这个实例</span></span><br><span class="line"><span class="comment">     * (4)强调这是一个单例,我们可以用final修饰</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton_1</span> </span>&#123;</span><br><span class="line">        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> Singleton_1 INSTANCE = <span class="keyword">new</span> Singleton_1() ;</span><br><span class="line">        <span class="function"><span class="keyword">private</span> <span class="title">Singleton_1</span><span class="params">()</span></span>&#123;</span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>枚举式(最简洁) JDK1.5以后有枚举类 (枚举类的构造器都是私有化)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * 枚举类型:表示该类型的对象是有限的几个</span></span><br><span class="line"><span class="comment">  * 我们可以限定为一个,就成了单例</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">enum</span> Singleton_2 &#123;</span><br><span class="line">      INSTANCE;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>
<p>静态代码块饿汉式(适合复杂实例化)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton_3</span> </span>&#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> Singleton_3 INSTANCE ;</span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line">        INSTANCE = <span class="keyword">new</span> Singleton_3();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton_3</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="为什么饿汉式是线程安全的？（算是自己总结的）"><a href="#为什么饿汉式是线程安全的？（算是自己总结的）" class="headerlink" title="#为什么饿汉式是线程安全的？（算是自己总结的）"></a>#为什么饿汉式是线程安全的？（算是自己总结的）</h5><p>java设计的类加载器就可以避免线程安全的问题，在类初始化的时候就已经创建好实例对象，一个类在整个生命周期只会加载一次，也就是说每次线程只会拿到一个对象，所以说是线程安全的。</p>
</li>
<li><p>懒汉式:延迟创建对象<br>线程不安全(适用于单线程) </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 懒汉式单例</span></span><br><span class="line"><span class="comment"> *  (1)构造器私有化 </span></span><br><span class="line"><span class="comment"> *  (2)用一个静态变量保存这个唯一的实例</span></span><br><span class="line"><span class="comment"> *  (3)提供一个静态方法,获取这个实例对象</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton_4</span> </span>&#123;</span><br><span class="line">        <span class="keyword">private</span> <span class="keyword">static</span> Singleton_4 instance ;</span><br><span class="line">        <span class="function"><span class="keyword">private</span> <span class="title">Singleton_4</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton_4 <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">            <span class="keyword">if</span> (instance==<span class="keyword">null</span>)&#123;</span><br><span class="line">                instance = <span class="keyword">new</span> Singleton_4();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> instance;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<p>线程安全(适用于多线程) </p>
 <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton_4</span> </span>&#123;</span><br><span class="line">        <span class="keyword">private</span> <span class="keyword">static</span> Singleton_4 instance ;</span><br><span class="line">        <span class="function"><span class="keyword">private</span> <span class="title">Singleton_4</span><span class="params">()</span></span>&#123;</span><br><span class="line">    </span><br><span class="line">        &#125;</span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton_4 <span class="title">getInstance</span><span class="params">()</span>  </span>&#123;</span><br><span class="line">            <span class="keyword">synchronized</span>(Singleton_4.class)&#123;</span><br><span class="line">                <span class="keyword">if</span> (instance==<span class="keyword">null</span>)&#123;</span><br><span class="line">                    instance =  <span class="keyword">new</span> Singleton_4();</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> instance;</span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>静态内部类形式(适用于多线程)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 在内部类被加载和初始化时,オ创建INSTANCE实例对象</span></span><br><span class="line"><span class="comment"> * 静态内部类不会自动随着外部类的加载和初始化而初始化,它是要单独去加载和初始化的。</span></span><br><span class="line"><span class="comment"> * 因为是在内部类加载和初始化创建的，所以是线程安全的</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton_5</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton_5</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Inner</span></span>&#123;</span><br><span class="line">        <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Singleton_5 INSTANCE = <span class="keyword">new</span> Singleton_5();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton_5 <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> Inner.INSTANCE;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>

  </div>
</article>



    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
    <div id="vcomments" class="blog-post-comments"></div>
    <script>
        new Valine({
            el: '#vcomments',
            visitor: true,
            appId: '9SOu7w0vk3EgLYD9bplRRAjj-gzGzoHsz',
            appKey: 'FhRym564Vv3ER20zASRmVOiR',
            placeholder: 'ヾﾉ≧∀≦)o来啊，快活啊!',
            avatar: 'robohash'
        })
    </script>


        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#什么是单例-（这个我就感觉是一堆废话）"><span class="toc-number">1.</span> <span class="toc-text">什么是单例 （这个我就感觉是一堆废话）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#要点（算是概括的蛮好的，也算单例模式的特点）"><span class="toc-number">2.</span> <span class="toc-text">要点（算是概括的蛮好的，也算单例模式的特点）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#几种常见模式"><span class="toc-number">3.</span> <span class="toc-text">几种常见模式</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#为什么饿汉式是线程安全的？（算是自己总结的）"><span class="toc-number">3.0.0.1.</span> <span class="toc-text">#为什么饿汉式是线程安全的？（算是自己总结的）</span></a></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&text=java学习笔记|单例模式"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&is_video=false&description=java学习笔记|单例模式"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=java学习笔记|单例模式&body=Check out this article: http://0cmm.cn/2020/05/22/java学习笔记-单例模式/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&title=java学习笔记|单例模式"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://0cmm.cn/2020/05/22/java学习笔记-单例模式/&name=java学习笔记|单例模式&description="><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy; 2020 0cm
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </nav>
  </div>

  
        <!-- 不蒜子统计 -->
        <span id="busuanzi_container_site_pv">
                本站总访问量<span id="busuanzi_value_site_pv"></span>次
        </span>
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  
  
</footer>



    </div>
    <!-- styles -->
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">

    <!-- jquery -->
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>
<!-- clipboard -->

  <script src="/lib/clipboard/clipboard.min.js"></script>
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight .code pre").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      target: function(trigger) {
        return trigger.nextElementSibling;
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>

<script src="/js/main.js"></script>
<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Disqus Comments -->


</body>
</html>
